<?php
class Sfs_View_Helper_NavMenu
{
    function NavMenu()
    {
        $username = Zend_Auth::getInstance()->getIdentity()->username;
        if (!$username)
        $username = 'Guest';
        $menu = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->nav_menu;
        if (count($menu)==0)
        return array();

        $fc = Zend_Controller_Front::getInstance();
//        $baseUrl = $fc->getBaseUrl();
        $moduleName = $fc->getRequest()->getModuleName();
        //		return $fc->getBaseUrl().'/themes/'.$view->config['layout'];
        $acl = Zend_Registry::get('acl');
        $arr = array();
        foreach ($menu->item as $val) {
            if ($acl->userIsAllowed($username,$moduleName,(string)$val->url))
            $arr[] = $val;
        }
        return $arr;
    }



}